<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title></title>
    <script src="js/mui.min.js"></script>
    <link href="css/mui.min.css" rel="stylesheet"/>
    <link rel="stylesheet" type="text/css" href="css/header.css"/>
	<link rel="stylesheet" type="text/css" href="fonticon/iconfont.css"/>
	<script type="text/javascript" charset="utf-8">
      	mui.init();
		/* 设备准备就绪 */
		mui.plusReady(function () {
			//让标题和系统颜色一致
			plus.navigator.setStatusBarStyle("light");
		    plus.navigator.setStatusBarBackground("#C9394A");
		});
    </script>
</head>
<body>
	<!-- 头部 -->
	<header class="mui-bar mui-bar-nav title">
		<h1 class="mui-title title-color"><b>DuckerChat</b></h1>
	</header>
	<!-- 尾部导航 -->
	<nav class="mui-bar mui-bar-tab">
		<a class="mui-tab-item mui-active" tabindex="0">
			<span class="mui-icon mui-icon-weixin"></span>
			<span class="mui-tab-label">微信</span>
		</a>
		<a class="mui-tab-item" tabindex="1">
			<span class="mui-icon mui-icon-contact"></span>
			<span class="mui-tab-label">通讯录</span>
		</a>
		<a class="mui-tab-item" tabindex="2">
			<span class="mui-icon mui-icon-paperplane"></span>
			<span class="mui-tab-label">发现</span>
		</a>
		<a class="mui-tab-item" tabindex="3">
			<span class="mui-icon mui-icon-person"></span>
			<span class="mui-tab-label">我</span>
		</a>
	</nav>
	
	<script>
		var navArray = [
			{
				pageId:"chatlist.html",
				pageUrl:"chatlist.html"
			},
			{
				pageId:"contact.html",
				pageUrl:"contact.html"
			},
			{
				pageId:"discover.html",
				pageUrl:"discover.html"
			},
			{
				pageId:"me.html",
				pageUrl:"me.html"
			},
		];
		
		// 页面可是区域设定 留出头部和导航
		var navStyle = {
			top: "44px",
			bottom: "50px"
		}
		
		mui.plusReady(function(){
			// 获取当前webview对象
			var indexWebview = plus.webview.currentWebview();

			// 向当前的主页webview追加子页的4张webview对象
			for (var i = 0 ; i < navArray.length ; i ++) {
				var navPage = plus.webview.create(navArray[i].pageUrl, 
													navArray[i].pageId,
													navStyle);
				// 隐藏webview窗口
				navPage.hide();
				// 追加每一个子页面到当前主页面
				indexWebview.append(navPage);
			}
			plus.webview.show(navArray[0].pageId);
			// 绑定nav事件
			mui(".mui-bar-tab").on("tap", "a", function() {
				var tabindex = this.getAttribute("tabindex");
				
				// 显示点击的tab选项所对应的页面
				plus.webview.show(navArray[tabindex].pageId, "fade-in", 200);
				
				// 隐藏其他的不需要的页面
				for (var i = 0 ; i < navArray.length ; i ++) {
					if (i != tabindex) {
						plus.webview.hide(navArray[i].pageId, "fade-out", 200);
					}
				}
			})
		})
	</script>
</body>
</html>